package com.yilin.tms.user.controller;

import com.yilin.tms.core.application.ReturnData;
import com.yilin.tms.core.commons.base.BaseController;
import com.yilin.tms.core.commons.annotation.UserTarget;
import com.yilin.tms.core.entity.data.statistics.*;
import com.yilin.tms.core.entity.data.statistics.user.HatchStatistics;
import com.yilin.tms.core.entity.data.statistics.user.ShipperStatistics;
import com.yilin.tms.core.entity.data.statistics.user.TruckerStatistics;
import com.yilin.tms.core.entity.data.statistics.user.UserStatistics;
import com.yilin.tms.core.entity.user.UserType;
import com.yilin.tms.user.service.IStatisticsService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user/statistics/")
public class StatisticsController extends BaseController {
    @Resource
    private IStatisticsService statisticsService;

    /**
     * 获取用户统计数据
     */
    @PostMapping("getUserStatistics")
    public ReturnData<UserStatistics> getUserStatistics() {
        UserStatistics userStatistics = statisticsService.getUserStatistics(getLoginUser());
        return jsonView(true, "获取成功", userStatistics);
    }

    /**
     * 获取孵化统计数据
     */
    @PostMapping("getHatchStatistics")
    public ReturnData<HatchStatistics> getHatchStatistics() {
        HatchStatistics hatchStatistics = statisticsService.getHatchStatistics(getLoginUser());
        return jsonView(true, "获取成功", hatchStatistics);
    }

    /**
     * 获取货主统计数据
     */
    @PostMapping("getShipperStatistics")
    public ReturnData<ShipperStatistics> getShipperStatistics() {
        ShipperStatistics shipperStatistics = statisticsService.getShipperStatistics(getLoginUser());
        return jsonView(true, "获取成功", shipperStatistics);
    }

    /**
     * 获取车主统计数据
     */
    @PostMapping("getTruckerStatistics")
    public ReturnData<TruckerStatistics> getTruckerStatistics() {
        TruckerStatistics truckerStatistics = statisticsService.getTruckerStatistics(getLoginUser());
        return jsonView(true, "获取成功", truckerStatistics);
    }

    /**
     * 用户证件未认证统计
     */
    @PostMapping(value = "getUserNoAuthStatistics")
    public ReturnData<UserNoAuthStatistics> getUserNoAuthStatistics() {
        UserNoAuthStatistics userNoAuthStatistics = statisticsService.getUserNoAuthStatistics();
        return jsonView(true, "获取用户证件未认证统计成功！",userNoAuthStatistics);
    }
}
